home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume6 / tetrix < prev    next >
Encoding:
Internet Message Format  |  1989-02-28  |  54.2 KB

  1. Path: uunet!tektronix!tekgen!tekred!games
  2. From: games@tekred.CNA.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v06i015:  tetrix - ancient Russian(?) fill the holes game
  5. Message-ID: <3662@tekred.CNA.TEK.COM>
  6. Date: 28 Feb 89 20:00:21 GMT
  7. Sender: billr@tekred.CNA.TEK.COM
  8. Lines: 2055
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: ncrlnk!ncrcae!quentin@uunet.uu.net
  12. Posting-number: Volume 6, Issue 15
  13. Archive-name: tetrix
  14.  
  15.     [I haven't been able to try this, not having a System V OS,
  16.      but it sounds like fun.  -br]
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of shell archive."
  25. # Contents:  README Rotate.c Makefile tet.h AdvanceP.c MoveL.c MoveR.c
  26. #   NewP.c Rotate.c tet.c
  27. # Wrapped by billr@saab on Tue Feb 28 11:22:44 1989
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'README' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'README'\"
  31. else
  32. echo shar: Extracting \"'README'\" \(1828 characters\)
  33. sed "s/^X//" >'README' <<'END_OF_FILE'
  34. X        This is a Unix SysV implementation of a game that appeared on
  35. Xcomp.binaries.amiga a while ago. The author, Quentin Neill,
  36. Xsaw it on an amiga here at work, and ported it to curses 
  37. X(on his own time, of course ;-)  ).
  38. X    I'm not too sure about the history of tetrix.  Someone 
  39. Xsaid that the game originated in Russia, and that it is quite old.
  40. XWe became enthralled with the game on an Amiga, almost to the point
  41. Xof addiction.  That version had some documentation, but I never had
  42. Xthe chance to read it - I only played.  I considered writing a version
  43. Xin machine language for my Franklin junker at home, but settled on a
  44. XC implementation for unix machines.
  45. X    The object of the game is to keep the board clear for as long as
  46. Xpossible.  Pieces consisting of four blocks (hence the name TETRix) in the
  47. Xseven possible arrangements are sent down one at a time.  The player's
  48. Xjob is to find the best fit for the piece in the pile of blocks that have
  49. Xalready fallen.  He can rotate each piece and move it from side to side.  
  50. XIf the piece just played causes a complete row of blocks, that row is 
  51. Xerased and all blocks above it move down one row.  Points are awarded for
  52. Xcompleted rows - more for rows higher up on the board.  A piece may
  53. Xbe dropped from a height for additional points when the player feels it 
  54. Xis oriented correctly.  The game is over when no more pieces can be formed
  55. Xat the top of the board.
  56. X    There is one variable INIT_PAUSE in tet.c that compensates for
  57. Xdifferent machine speeds.  Set this higher if tetrix screams, and the 
  58. Xtime between each piece's movement will lengthen.  Set it lower if
  59. Xit crawls along too slowly.  On a Tower 32/800 with about 45 users on a
  60. Xbusy day, we do well with the value set at about 300.  On a Tower 32/200
  61. Xwith one user, the value was set at 1500.
  62. X
  63. X    Good luck!                    Quentin Neill
  64. X
  65. END_OF_FILE
  66. if test 1828 -ne `wc -c <'README'`; then
  67.     echo shar: \"'README'\" unpacked with wrong size!
  68. fi
  69. # end of 'README'
  70. fi
  71. if test -f 'Rotate.c' -a "${1}" != "-c" ; then 
  72.   echo shar: Will not clobber existing file \"'Rotate.c'\"
  73. else
  74. echo shar: Extracting \"'Rotate.c'\" \(6209 characters\)
  75. sed "s/^X//" >'Rotate.c' <<'END_OF_FILE'
  76. X
  77. X#include <curses.h>
  78. X#include "tet.h"
  79. X/*********************************************************************/
  80. X/* Switch on type of piece, find out if I can rotate */
  81. X/* If so, then do it */
  82. X/*********************************************************************/
  83. XRotate()
  84. X{
  85. Xswitch (Type) {
  86. X    /*  WHITE PIECES  */
  87. X    case W_TYPE   :  /* checked */
  88. X        if (IS_FREE(Column,Row-1)) {
  89. X            PUTCH(Column-1,Row,NO_CHAR);
  90. X            PUTCH(Column,Row-1,W_CHAR);
  91. X            Type--;
  92. X            }
  93. X        else goto beepout;
  94. X        goto out;
  95. X    case W_TYPE-1 :  /* checked */
  96. X        if (IS_FREE(Column-1,Row)) {
  97. X            PUTCH(Column,Row+1,NO_CHAR);
  98. X            PUTCH(Column-1,Row,W_CHAR);
  99. X            Type--;
  100. X            }
  101. X        else goto beepout;
  102. X        goto out;
  103. X    case W_TYPE-2 :  /* checked */
  104. X        if (IS_FREE(Column,Row+1)) {
  105. X            PUTCH(Column+1,Row,NO_CHAR);
  106. X            PUTCH(Column,Row+1,W_CHAR);
  107. X            Type--;
  108. X            }
  109. X        else goto beepout;
  110. X        goto out;
  111. X    case W_TYPE-3 :  /* checked */
  112. X        if (IS_FREE(Column+1,Row)) {
  113. X            PUTCH(Column,Row-1,NO_CHAR);
  114. X            PUTCH(Column+1,Row,W_CHAR);
  115. X            Type = W_TYPE;
  116. X            }
  117. X        else goto beepout;
  118. X        goto out;
  119. X
  120. X    /*  RED PIECES  */
  121. X    case R_TYPE   : /* checked */
  122. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column,Row+1) && 
  123. X            IS_FREE(Column+1,Row+1)) {
  124. X            PUTCH(Column-1,Row,NO_CHAR);
  125. X            PUTCH(Column-1,Row+1,NO_CHAR);
  126. X            PUTCH(Column+1,Row,NO_CHAR);
  127. X            PUTCH(Column,Row-1,R_CHAR);
  128. X            PUTCH(Column,Row+1,R_CHAR);
  129. X            PUTCH(Column+1,Row+1,R_CHAR);
  130. X            Type--;
  131. X            }
  132. X        else goto beepout;
  133. X        goto out;
  134. X    case R_TYPE-1 : /* checked */
  135. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column+1,Row-1) && 
  136. X            IS_FREE(Column+1,Row)) {
  137. X            PUTCH(Column,Row-1,NO_CHAR);
  138. X            PUTCH(Column,Row+1,NO_CHAR);
  139. X            PUTCH(Column+1,Row+1,NO_CHAR);
  140. X            PUTCH(Column-1,Row,R_CHAR);
  141. X            PUTCH(Column+1,Row-1,R_CHAR);
  142. X            PUTCH(Column+1,Row,R_CHAR);
  143. X            Type--;
  144. X            }
  145. X        else goto beepout;
  146. X        goto out;
  147. X    case R_TYPE-2 : /* checked  */
  148. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column,Row-1) && 
  149. X            IS_FREE(Column,Row+1)) {
  150. X            PUTCH(Column-1,Row,NO_CHAR);
  151. X            PUTCH(Column+1,Row-1,NO_CHAR);
  152. X            PUTCH(Column+1,Row,NO_CHAR);
  153. X            PUTCH(Column-1,Row-1,R_CHAR);
  154. X            PUTCH(Column,Row-1,R_CHAR);
  155. X            PUTCH(Column,Row+1,R_CHAR);
  156. X            Type--;
  157. X            }
  158. X        else goto beepout;
  159. X        goto out;
  160. X    case R_TYPE-3 : /* checked */
  161. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column-1,Row+1) && 
  162. X            IS_FREE(Column+1,Row)) {
  163. X            PUTCH(Column-1,Row-1,NO_CHAR);
  164. X            PUTCH(Column,Row-1,NO_CHAR);
  165. X            PUTCH(Column,Row+1,NO_CHAR);
  166. X            PUTCH(Column-1,Row,R_CHAR);
  167. X            PUTCH(Column-1,Row+1,R_CHAR);
  168. X            PUTCH(Column+1,Row,R_CHAR);
  169. X            Type = R_TYPE;
  170. X            }
  171. X        else goto beepout;
  172. X        goto out;
  173. X
  174. X    /*  TAN PIECES  */
  175. X    case T_TYPE   :
  176. X    case T_TYPE-1 :
  177. X    case T_TYPE-2 :
  178. X    case T_TYPE-3 : goto out;
  179. X
  180. X    /*  YELLOW PIECES  */
  181. X    case Y_TYPE   :
  182. X    case Y_TYPE-2 :  /* checked */
  183. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column+1,Row+1)) {
  184. X            PUTCH(Column-1,Row+1,NO_CHAR);
  185. X            PUTCH(Column,Row+1,NO_CHAR);
  186. X            PUTCH(Column,Row-1,Y_CHAR);
  187. X            PUTCH(Column+1,Row+1,Y_CHAR);
  188. X            Type--;
  189. X            }
  190. X        else goto beepout;
  191. X        goto out;
  192. X    case Y_TYPE-1 :
  193. X    case Y_TYPE-3 : /* checked */
  194. X        if (IS_FREE(Column-1,Row+1) && IS_FREE(Column,Row+1)) {
  195. X            PUTCH(Column,Row-1,NO_CHAR);
  196. X            PUTCH(Column+1,Row+1,NO_CHAR);
  197. X            PUTCH(Column-1,Row+1,Y_CHAR);
  198. X            PUTCH(Column,Row+1,Y_CHAR);
  199. X            Type = Y_TYPE;
  200. X            }
  201. X        else goto beepout;
  202. X        goto out;
  203. X
  204. X    /*  GREEN PIECES  */
  205. X    case G_TYPE   :
  206. X    case G_TYPE-2 : /* checked */
  207. X        if (IS_FREE(Column-1,Row+1) && IS_FREE(Column,Row-1)) {
  208. X            PUTCH(Column,Row+1,NO_CHAR);
  209. X            PUTCH(Column+1,Row+1,NO_CHAR);
  210. X            PUTCH(Column-1,Row+1,G_CHAR);
  211. X            PUTCH(Column,Row-1,G_CHAR);
  212. X            Type--;
  213. X            }
  214. X        else goto beepout;
  215. X        goto out;
  216. X    case G_TYPE-1 :
  217. X    case G_TYPE-3 : /* checked */
  218. X        if (IS_FREE(Column,Row+1) && IS_FREE(Column+1,Row+1)) {
  219. X            PUTCH(Column-1,Row+1,NO_CHAR);
  220. X            PUTCH(Column,Row-1,NO_CHAR);
  221. X            PUTCH(Column,Row+1,G_CHAR);
  222. X            PUTCH(Column+1,Row+1,G_CHAR);
  223. X            Type = G_TYPE;
  224. X            }
  225. X        else goto beepout;
  226. X        goto out;
  227. X
  228. X
  229. X    /*  BLUE PIECES  */
  230. X    case B_TYPE   : /* checked */
  231. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column,Row+1) && 
  232. X            IS_FREE(Column+1,Row-1)) {
  233. X            PUTCH(Column-1,Row,NO_CHAR);
  234. X            PUTCH(Column+1,Row,NO_CHAR);
  235. X            PUTCH(Column+1,Row+1,NO_CHAR);
  236. X            PUTCH(Column,Row-1,B_CHAR);
  237. X            PUTCH(Column,Row+1,B_CHAR);
  238. X            PUTCH(Column+1,Row-1,B_CHAR);
  239. X            Type--;
  240. X            }
  241. X        else goto beepout;
  242. X        goto out;
  243. X    case B_TYPE-1 : /* checked */
  244. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-1,Row) && 
  245. X            IS_FREE(Column+1,Row)) {
  246. X            PUTCH(Column,Row-1,NO_CHAR);
  247. X            PUTCH(Column,Row+1,NO_CHAR);
  248. X            PUTCH(Column+1,Row-1,NO_CHAR);
  249. X            PUTCH(Column-1,Row-1,B_CHAR);
  250. X            PUTCH(Column-1,Row,B_CHAR);
  251. X            PUTCH(Column+1,Row,B_CHAR);
  252. X            Type--;
  253. X            }
  254. X        else goto beepout;
  255. X        goto out;
  256. X    case B_TYPE-2 : /* checked  */
  257. X        if (IS_FREE(Column-1,Row+1) && IS_FREE(Column,Row-1) && 
  258. X            IS_FREE(Column,Row+1)) {
  259. X            PUTCH(Column-1,Row-1,NO_CHAR);
  260. X            PUTCH(Column-1,Row,NO_CHAR);
  261. X            PUTCH(Column+1,Row,NO_CHAR);
  262. X            PUTCH(Column-1,Row+1,B_CHAR);
  263. X            PUTCH(Column,Row-1,B_CHAR);
  264. X            PUTCH(Column,Row+1,B_CHAR);
  265. X            Type--;
  266. X            }
  267. X        else goto beepout;
  268. X        goto out;
  269. X    case B_TYPE-3 : /* checked */
  270. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column+1,Row) && 
  271. X            IS_FREE(Column+1,Row+1)) {
  272. X            PUTCH(Column-1,Row+1,NO_CHAR);
  273. X            PUTCH(Column,Row-1,NO_CHAR);
  274. X            PUTCH(Column,Row+1,NO_CHAR);
  275. X            PUTCH(Column-1,Row,B_CHAR);
  276. X            PUTCH(Column+1,Row,B_CHAR);
  277. X            PUTCH(Column+1,Row+1,B_CHAR);
  278. X            Type = B_TYPE;
  279. X            }
  280. X        else goto beepout;
  281. X        goto out;
  282. X
  283. X    /*  VIOLET PIECES  */
  284. X    case V_TYPE   :
  285. X    case V_TYPE-2 : /* checked */
  286. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column,Row+1) && 
  287. X            IS_FREE(Column,Row+2)) {
  288. X            PUTCH(Column-1,Row,NO_CHAR);
  289. X            PUTCH(Column+1,Row,NO_CHAR);
  290. X            PUTCH(Column+2,Row,NO_CHAR);
  291. X            PUTCH(Column,Row-1,V_CHAR);
  292. X            PUTCH(Column,Row+1,V_CHAR);
  293. X            PUTCH(Column,Row+2,V_CHAR);
  294. X            Type--;
  295. X            }
  296. X        else goto beepout;
  297. X        goto out;
  298. X    case V_TYPE-1 :
  299. X    case V_TYPE-3 : /* checked */
  300. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column+1,Row) && 
  301. X            IS_FREE(Column+2,Row)) {
  302. X            PUTCH(Column,Row-1,NO_CHAR);
  303. X            PUTCH(Column,Row+1,NO_CHAR);
  304. X            PUTCH(Column,Row+2,NO_CHAR);
  305. X            PUTCH(Column-1,Row,V_CHAR);
  306. X            PUTCH(Column,Row,V_CHAR);
  307. X            PUTCH(Column+1,Row,V_CHAR);
  308. X            PUTCH(Column+2,Row,V_CHAR);
  309. X            Type = V_TYPE;
  310. X            }
  311. X        else goto beepout;
  312. X        goto out;
  313. X    default : 
  314. X        printf("illegal piece Type=%d!!\n",Type); 
  315. X        exit();
  316. X    }
  317. Xbeepout:
  318. X    if (Beep) beep();
  319. Xout:
  320. X    refresh();
  321. X}
  322. X
  323. END_OF_FILE
  324. if test 6209 -ne `wc -c <'Rotate.c'`; then
  325.     echo shar: \"'Rotate.c'\" unpacked with wrong size!
  326. fi
  327. # end of 'Rotate.c'
  328. fi
  329. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  330.   echo shar: Will not clobber existing file \"'Makefile'\"
  331. else
  332. echo shar: Extracting \"'Makefile'\" \(633 characters\)
  333. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  334. X#  - un'cpio' this in /usr/src or /usr/local/src or something - doesn't matter.
  335. X#  - do a 'make install' in the tetrix directory
  336. X#  - tetrix gets installed in /usr/lbin
  337. X#  - this will create a high score file in /usr/tmp, so doing it again
  338. X#    later on will erase high scores for the machine.
  339. X
  340. X
  341. XOBJS= MoveR.o MoveL.o NewP.o AdvanceP.o Rotate.o tet.o
  342. XINCS= tet.h
  343. X
  344. Xtetrix: $(OBJS) $(INCS)
  345. X    cc -O $(OBJS) -o tetrix -lcurses
  346. X
  347. XMoveR.o: MoveR.c
  348. X
  349. XMoveL.o: MoveL.c
  350. X
  351. XNewP.o: NewP.c
  352. X
  353. XAdvanceP.o: AdvanceP.c
  354. X
  355. XRotate.o: Rotate.c
  356. X
  357. Xtet.o: tet.c
  358. X
  359. Xinstall: tetrix
  360. X    chmod 755 tetrix
  361. X    /bin/mv -f tetrix /usr/lbin
  362. X
  363. Xclean:
  364. X    /bin/rm -rf tetrix core *.o
  365. END_OF_FILE
  366. if test 633 -ne `wc -c <'Makefile'`; then
  367.     echo shar: \"'Makefile'\" unpacked with wrong size!
  368. fi
  369. # end of 'Makefile'
  370. fi
  371. if test -f 'tet.h' -a "${1}" != "-c" ; then 
  372.   echo shar: Will not clobber existing file \"'tet.h'\"
  373. else
  374. echo shar: Extracting \"'tet.h'\" \(1261 characters\)
  375. sed "s/^X//" >'tet.h' <<'END_OF_FILE'
  376. X#define NO_TYPE    0
  377. X#define NO_CHAR    ' '
  378. X#define BRITE_CHAR '$'
  379. X
  380. X/* type numbers 1-3, 4-7, 9-11 etc represent the white, red, blue etc */
  381. X/* pieces at different rotations */
  382. X#define G_TYPE    4        /* Green pieces */
  383. X#define G_CHAR    'G'
  384. X#define R_TYPE    8        /* Red pieces */
  385. X#define R_CHAR    'R'
  386. X#define T_TYPE  12        /* Tan pieces */
  387. X#define T_CHAR    'O'
  388. X#define W_TYPE    16        /* White pieces */
  389. X#define W_CHAR    'W'
  390. X#define V_TYPE    20        /* Violet pieces */
  391. X#define V_CHAR    'V'
  392. X#define B_TYPE    24        /* Blue pieces */
  393. X#define B_CHAR    'B'
  394. X#define Y_TYPE    28        /* Yellow pieces */
  395. X#define Y_CHAR    'Y'
  396. X
  397. X#define MINX 15        /* defines corner screen position */
  398. X#define MINY 1
  399. X
  400. X#define BOARD_WIDE 10
  401. X#define BOARD_HIGH 20
  402. X
  403. X#define MAXX BOARD_WIDE+MINX
  404. X#define MAXY BOARD_HIGH+MINY
  405. X
  406. X#define STARTROW 1        /* defines starting position of pieces */
  407. X#define STARTCOL 5
  408. X
  409. Xextern int Type, Row, Column, Pause, CurrentSpeed, FallingDown, Beep;
  410. Xextern char Board[BOARD_WIDE][BOARD_HIGH];
  411. X
  412. X/* Macros */
  413. X/* offset the character on screen by MINX and MINY */
  414. X#define PUTCH(x,y,z) {  mvaddch(y+MINY,x+MINX,z); Board[x][y]=z; }
  415. X
  416. X/* test whether a square is empty and legal */
  417. X/*
  418. X#define IS_FREE(x,y)  (((y >= 0) && (y < BOARD_HIGH) && \
  419. X            (x >= 0) && (x < BOARD_WIDE)) && \
  420. X            (Board[x][y] == NO_CHAR))
  421. X*/
  422. XIS_FREE();
  423. END_OF_FILE
  424. if test 1261 -ne `wc -c <'tet.h'`; then
  425.     echo shar: \"'tet.h'\" unpacked with wrong size!
  426. fi
  427. # end of 'tet.h'
  428. fi
  429. if test -f 'AdvanceP.c' -a "${1}" != "-c" ; then 
  430.   echo shar: Will not clobber existing file \"'AdvanceP.c'\"
  431. else
  432. echo shar: Extracting \"'AdvanceP.c'\" \(6864 characters\)
  433. sed "s/^X//" >'AdvanceP.c' <<'END_OF_FILE'
  434. X
  435. X#include <curses.h>
  436. X#include "tet.h"
  437. X/*********************************************************************/
  438. X/* Switch on type of piece, find out if I can move down */
  439. X/* If so, then do it and return 1 else return 0 */
  440. X/*********************************************************************/
  441. XAdvancePiece()
  442. X{
  443. Xswitch (Type) {
  444. X    /*  WHITE PIECES  */
  445. X    case W_TYPE    : 
  446. X            if (IS_FREE(Column-1,Row+1) && 
  447. X            IS_FREE(Column,Row+2) &&
  448. X            IS_FREE(Column+1,Row+1)) 
  449. X                {
  450. X                PUTCH(Column-1,Row,NO_CHAR);
  451. X                PUTCH(Column,Row,NO_CHAR);
  452. X                PUTCH(Column+1,Row,NO_CHAR);
  453. X                PUTCH(Column-1,Row+1,W_CHAR);
  454. X                PUTCH(Column,Row+2,W_CHAR);
  455. X                PUTCH(Column+1,Row+1,W_CHAR);
  456. X                Row +=1;
  457. X                goto out;
  458. X                }
  459. X            else goto badout;
  460. X
  461. X    case W_TYPE-1 :
  462. X            if (IS_FREE(Column,Row+2) && 
  463. X            IS_FREE(Column+1,Row+1))
  464. X                {
  465. X                PUTCH(Column,Row-1,NO_CHAR);
  466. X                PUTCH(Column+1,Row,NO_CHAR);
  467. X                PUTCH(Column,Row+2,W_CHAR);
  468. X                PUTCH(Column+1,Row+1,W_CHAR);
  469. X                Row +=1;
  470. X                goto out;
  471. X                }
  472. X            else goto badout;
  473. X
  474. X    case W_TYPE-2 :  
  475. X            if (IS_FREE(Column-1,Row+1) &&     
  476. X            IS_FREE(Column,Row+1) && 
  477. X            IS_FREE(Column+1,Row+1))
  478. X                {
  479. X                PUTCH(Column-1,Row,NO_CHAR);
  480. X                PUTCH(Column,Row-1,NO_CHAR);
  481. X                PUTCH(Column+1,Row,NO_CHAR);
  482. X                PUTCH(Column-1,Row+1,W_CHAR);
  483. X                PUTCH(Column,Row+1,W_CHAR);
  484. X                PUTCH(Column+1,Row+1,W_CHAR);
  485. X                Row +=1;
  486. X                goto out;
  487. X                }
  488. X            else goto badout;
  489. X
  490. X    case W_TYPE-3 :  
  491. X            if (IS_FREE(Column-1,Row+1) &&     
  492. X            IS_FREE(Column,Row+2))
  493. X                {
  494. X                PUTCH(Column-1,Row,NO_CHAR);
  495. X                PUTCH(Column,Row-1,NO_CHAR);
  496. X                PUTCH(Column-1,Row+1,W_CHAR);
  497. X                PUTCH(Column,Row+2,W_CHAR);
  498. X                Row +=1;
  499. X                goto out;
  500. X                }
  501. X            else goto badout;
  502. X
  503. X
  504. X    /*  RED PIECES  */
  505. X    case R_TYPE   : 
  506. X            if (IS_FREE(Column-1,Row+2) && 
  507. X            IS_FREE(Column,Row+1) &&
  508. X            IS_FREE(Column+1,Row+1))
  509. X                {
  510. X                PUTCH(Column-1,Row,NO_CHAR);
  511. X                PUTCH(Column,Row,NO_CHAR);
  512. X                PUTCH(Column+1,Row,NO_CHAR);
  513. X                PUTCH(Column-1,Row+2,R_CHAR);
  514. X                PUTCH(Column,Row+1,R_CHAR);
  515. X                PUTCH(Column+1,Row+1,R_CHAR);
  516. X                Row +=1;
  517. X                goto out;
  518. X                }
  519. X            else goto badout;
  520. X
  521. X    case R_TYPE-1 : 
  522. X            if (IS_FREE(Column,Row+2) && 
  523. X            IS_FREE(Column+1,Row+2))
  524. X                {
  525. X                PUTCH(Column,Row-1,NO_CHAR);
  526. X                PUTCH(Column+1,Row+1,NO_CHAR);
  527. X                PUTCH(Column,Row+2,R_CHAR);
  528. X                PUTCH(Column+1,Row+2,R_CHAR);
  529. X                Row +=1;
  530. X                goto out;
  531. X                }
  532. X            else goto badout;
  533. X
  534. X    case R_TYPE-2 : 
  535. X            if (IS_FREE(Column-1,Row+1) && 
  536. X            IS_FREE(Column,Row+1) &&
  537. X            IS_FREE(Column+1,Row+1))
  538. X                {
  539. X                PUTCH(Column-1,Row,NO_CHAR);
  540. X                PUTCH(Column,Row,NO_CHAR);
  541. X                PUTCH(Column+1,Row-1,NO_CHAR);
  542. X                PUTCH(Column-1,Row+1,R_CHAR);
  543. X                PUTCH(Column,Row+1,R_CHAR);
  544. X                PUTCH(Column+1,Row+1,R_CHAR);
  545. X                Row +=1;
  546. X                goto out;
  547. X                }
  548. X            else goto badout;
  549. X
  550. X    case R_TYPE-3 : 
  551. X            if (IS_FREE(Column-1,Row) && 
  552. X            IS_FREE(Column,Row+2))
  553. X                {
  554. X                PUTCH(Column-1,Row-1,NO_CHAR);
  555. X                PUTCH(Column,Row-1,NO_CHAR);
  556. X                PUTCH(Column-1,Row,R_CHAR);
  557. X                PUTCH(Column,Row+2,R_CHAR);
  558. X                Row +=1;
  559. X                goto out;
  560. X                }
  561. X            else goto badout;
  562. X
  563. X
  564. X    /*  TAN PIECES  */
  565. X    case T_TYPE   :
  566. X    case T_TYPE-1 :
  567. X    case T_TYPE-2 :
  568. X    case T_TYPE-3 :
  569. X            if (IS_FREE(Column,Row+2) && 
  570. X            IS_FREE(Column+1,Row+2))
  571. X                {
  572. X                PUTCH(Column,Row,NO_CHAR);
  573. X                PUTCH(Column+1,Row,NO_CHAR);
  574. X                PUTCH(Column,Row+2,T_CHAR);
  575. X                PUTCH(Column+1,Row+2,T_CHAR);
  576. X                Row +=1;
  577. X                goto out;
  578. X                }
  579. X            else goto badout;
  580. X
  581. X
  582. X    /*  YELLOW PIECES  */
  583. X    case Y_TYPE   :
  584. X    case Y_TYPE-2 :  
  585. X            if (IS_FREE(Column-1,Row+2) && 
  586. X            IS_FREE(Column,Row+2) &&
  587. X            IS_FREE(Column+1,Row+1))
  588. X                {
  589. X                PUTCH(Column-1,Row+1,NO_CHAR);
  590. X                PUTCH(Column,Row,NO_CHAR);
  591. X                PUTCH(Column+1,Row,NO_CHAR);
  592. X                PUTCH(Column-1,Row+2,Y_CHAR);
  593. X                PUTCH(Column,Row+2,Y_CHAR);
  594. X                PUTCH(Column+1,Row+1,Y_CHAR);
  595. X                Row +=1;
  596. X                goto out;
  597. X                }
  598. X            else goto badout;
  599. X
  600. X    case Y_TYPE-1 :
  601. X    case Y_TYPE-3 : 
  602. X            if (IS_FREE(Column,Row+1) && 
  603. X            IS_FREE(Column+1,Row+2))
  604. X                {
  605. X                PUTCH(Column,Row-1,NO_CHAR);
  606. X                PUTCH(Column+1,Row,NO_CHAR);
  607. X                PUTCH(Column,Row+1,Y_CHAR);
  608. X                PUTCH(Column+1,Row+2,Y_CHAR);
  609. X                Row +=1;
  610. X                goto out;
  611. X                }
  612. X            else goto badout;
  613. X
  614. X
  615. X    /*  GREEN PIECES  */
  616. X    case G_TYPE   :
  617. X    case G_TYPE-2 : 
  618. X            if (IS_FREE(Column-1,Row+1) && 
  619. X            IS_FREE(Column,Row+2) &&
  620. X            IS_FREE(Column+1,Row+2))
  621. X                {
  622. X                PUTCH(Column-1,Row,NO_CHAR);
  623. X                PUTCH(Column,Row,NO_CHAR);
  624. X                PUTCH(Column+1,Row+1,NO_CHAR);
  625. X                PUTCH(Column-1,Row+1,G_CHAR);
  626. X                PUTCH(Column,Row+2,G_CHAR);
  627. X                PUTCH(Column+1,Row+2,G_CHAR);
  628. X                Row +=1;
  629. X                goto out;
  630. X                }
  631. X            else goto badout;
  632. X
  633. X    case G_TYPE-1 :
  634. X    case G_TYPE-3 : 
  635. X            if (IS_FREE(Column-1,Row+2) && 
  636. X            IS_FREE(Column,Row+1))
  637. X                {
  638. X                PUTCH(Column,Row-1,NO_CHAR);
  639. X                PUTCH(Column-1,Row,NO_CHAR);
  640. X                PUTCH(Column,Row+1,G_CHAR);
  641. X                PUTCH(Column-1,Row+2,G_CHAR);
  642. X                Row +=1;
  643. X                goto out;
  644. X                }
  645. X            else goto badout;
  646. X
  647. X
  648. X    /*  BLUE PIECES  */
  649. X    case B_TYPE   : 
  650. X            if (IS_FREE(Column-1,Row+1) && 
  651. X            IS_FREE(Column,Row+1) &&
  652. X            IS_FREE(Column+1,Row+2))
  653. X                {
  654. X                PUTCH(Column-1,Row,NO_CHAR);
  655. X                PUTCH(Column,Row,NO_CHAR);
  656. X                PUTCH(Column+1,Row,NO_CHAR);
  657. X                PUTCH(Column-1,Row+1,B_CHAR);
  658. X                PUTCH(Column,Row+1,B_CHAR);
  659. X                PUTCH(Column+1,Row+2,B_CHAR);
  660. X                Row +=1;
  661. X                goto out;
  662. X                }
  663. X            else goto badout;
  664. X
  665. X    case B_TYPE-1 : 
  666. X            if (IS_FREE(Column,Row+2) && 
  667. X            IS_FREE(Column+1,Row))
  668. X                {
  669. X                PUTCH(Column,Row-1,NO_CHAR);
  670. X                PUTCH(Column+1,Row-1,NO_CHAR);
  671. X                PUTCH(Column,Row+2,B_CHAR);
  672. X                PUTCH(Column+1,Row,B_CHAR);
  673. X                Row +=1;
  674. X                goto out;
  675. X                }
  676. X            else goto badout;
  677. X
  678. X    case B_TYPE-2 : 
  679. X            if (IS_FREE(Column-1,Row+1) && 
  680. X            IS_FREE(Column,Row+1) &&
  681. X            IS_FREE(Column+1,Row+1))
  682. X                {
  683. X                PUTCH(Column-1,Row-1,NO_CHAR);
  684. X                PUTCH(Column,Row,NO_CHAR);
  685. X                PUTCH(Column+1,Row,NO_CHAR);
  686. X                PUTCH(Column-1,Row+1,B_CHAR);
  687. X                PUTCH(Column,Row+1,B_CHAR);
  688. X                PUTCH(Column+1,Row+1,B_CHAR);
  689. X                Row +=1;
  690. X                goto out;
  691. X                }
  692. X            else goto badout;
  693. X
  694. X    case B_TYPE-3 : 
  695. X            if (IS_FREE(Column-1,Row+2) && 
  696. X            IS_FREE(Column,Row+2))
  697. X                {
  698. X                PUTCH(Column-1,Row+1,NO_CHAR);
  699. X                PUTCH(Column,Row-1,NO_CHAR);
  700. X                PUTCH(Column-1,Row+2,B_CHAR);
  701. X                PUTCH(Column,Row+2,B_CHAR);
  702. X                Row +=1;
  703. X                goto out;
  704. X                }
  705. X            else goto badout;
  706. X
  707. X
  708. X    /*  VIOLET PIECES  */
  709. X    case V_TYPE   :
  710. X    case V_TYPE-2 : 
  711. X            if (IS_FREE(Column-1,Row+1) && 
  712. X            IS_FREE(Column,Row+1) && 
  713. X            IS_FREE(Column+1,Row+1) && 
  714. X            IS_FREE(Column+2,Row+1))
  715. X                {
  716. X                PUTCH(Column-1,Row,NO_CHAR);
  717. X                PUTCH(Column,Row,NO_CHAR);
  718. X                PUTCH(Column+1,Row,NO_CHAR);
  719. X                PUTCH(Column+2,Row,NO_CHAR);
  720. X                PUTCH(Column-1,Row+1,V_CHAR);
  721. X                PUTCH(Column,Row+1,V_CHAR);
  722. X                PUTCH(Column+1,Row+1,V_CHAR);
  723. X                PUTCH(Column+2,Row+1,V_CHAR);
  724. X                Row +=1;
  725. X                goto out;
  726. X                }
  727. X            else goto badout;
  728. X
  729. X    case V_TYPE-1 :
  730. X    case V_TYPE-3 : 
  731. X            if (IS_FREE(Column,Row+3)) 
  732. X                {
  733. X                PUTCH(Column,Row-1,NO_CHAR);
  734. X                PUTCH(Column,Row+3,V_CHAR);
  735. X                Row +=1;
  736. X                goto out;
  737. X                }
  738. X            else goto badout;
  739. X
  740. X    default : 
  741. X        printf("Advance Piece: illegal piece Type=%d!!\n",Type); 
  742. X        exit();
  743. X    }
  744. Xbadout:
  745. X    return(0);
  746. Xout:
  747. X    refresh();
  748. X    return(1);
  749. X}
  750. END_OF_FILE
  751. if test 6864 -ne `wc -c <'AdvanceP.c'`; then
  752.     echo shar: \"'AdvanceP.c'\" unpacked with wrong size!
  753. fi
  754. # end of 'AdvanceP.c'
  755. fi
  756. if test -f 'MoveL.c' -a "${1}" != "-c" ; then 
  757.   echo shar: Will not clobber existing file \"'MoveL.c'\"
  758. else
  759. echo shar: Extracting \"'MoveL.c'\" \(6741 characters\)
  760. sed "s/^X//" >'MoveL.c' <<'END_OF_FILE'
  761. X
  762. X#include <curses.h>
  763. X#include "tet.h"
  764. X/*********************************************************************/
  765. X/* Switch on type of piece, find out if I can move left */
  766. X/* If so, then do it */
  767. X/*********************************************************************/
  768. XMoveLeft()
  769. X{
  770. Xswitch (Type) {
  771. X    /*  WHITE PIECES  */
  772. X    case W_TYPE   :  /* checked */
  773. X        if (IS_FREE(Column-2,Row) && IS_FREE(Column-1,Row+1)) {
  774. X            PUTCH(Column+1,Row,NO_CHAR);
  775. X            PUTCH(Column,Row+1,NO_CHAR);
  776. X            PUTCH(Column-2,Row,W_CHAR);
  777. X            PUTCH(Column-1,Row+1,W_CHAR);
  778. X            Column -=1;
  779. X            }
  780. X        else goto beepout;
  781. X        goto out;
  782. X    case W_TYPE-1 :  /* checked */
  783. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-1,Row) && 
  784. X            IS_FREE(Column-1,Row+1)) {
  785. X            PUTCH(Column,Row-1,NO_CHAR);
  786. X            PUTCH(Column+1,Row,NO_CHAR);
  787. X            PUTCH(Column,Row+1,NO_CHAR);
  788. X            PUTCH(Column-1,Row-1,W_CHAR);
  789. X            PUTCH(Column-1,Row,W_CHAR);
  790. X            PUTCH(Column-1,Row+1,W_CHAR);
  791. X            Column -=1;
  792. X            }
  793. X        else goto beepout;
  794. X        goto out;
  795. X    case W_TYPE-2 :  /* checked */
  796. X        if (IS_FREE(Column-2,Row) && IS_FREE(Column-1,Row-1)) {
  797. X            PUTCH(Column+1,Row,NO_CHAR);
  798. X            PUTCH(Column,Row-1,NO_CHAR);
  799. X            PUTCH(Column-2,Row,W_CHAR);
  800. X            PUTCH(Column-1,Row-1,W_CHAR);
  801. X            Column -=1;
  802. X            }
  803. X        else goto beepout;
  804. X        goto out;
  805. X    case W_TYPE-3 :  /* checked */
  806. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-2,Row) && 
  807. X            IS_FREE(Column-1,Row+1)) {
  808. X            PUTCH(Column,Row-1,NO_CHAR);
  809. X            PUTCH(Column,Row,NO_CHAR);
  810. X            PUTCH(Column,Row+1,NO_CHAR);
  811. X            PUTCH(Column-1,Row-1,W_CHAR);
  812. X            PUTCH(Column-2,Row,W_CHAR);
  813. X            PUTCH(Column-1,Row+1,W_CHAR);
  814. X            Column -=1;
  815. X            }
  816. X        else goto beepout;
  817. X        goto out;
  818. X
  819. X    /*  RED PIECES  */
  820. X    case R_TYPE   : /* checked */
  821. X        if (IS_FREE(Column-2,Row) && IS_FREE(Column-2,Row+1)) {
  822. X            PUTCH(Column+1,Row,NO_CHAR);
  823. X            PUTCH(Column-1,Row+1,NO_CHAR);
  824. X            PUTCH(Column-2,Row,R_CHAR);
  825. X            PUTCH(Column-2,Row+1,R_CHAR);
  826. X            Column -=1;
  827. X            }
  828. X        else goto beepout;
  829. X        goto out;
  830. X    case R_TYPE-1 : /* checked */
  831. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-1,Row) && 
  832. X            IS_FREE(Column-1,Row+1)) {
  833. X            PUTCH(Column,Row-1,NO_CHAR);
  834. X            PUTCH(Column,Row,NO_CHAR);
  835. X            PUTCH(Column+1,Row+1,NO_CHAR);
  836. X            PUTCH(Column-1,Row-1,R_CHAR);
  837. X            PUTCH(Column-1,Row,R_CHAR);
  838. X            PUTCH(Column-1,Row+1,R_CHAR);
  839. X            Column -=1;
  840. X            }
  841. X        else goto beepout;
  842. X        goto out;
  843. X    case R_TYPE-2 : /* checked  */
  844. X        if (IS_FREE(Column-2,Row) && IS_FREE(Column,Row-1)) {
  845. X            PUTCH(Column+1,Row-1,NO_CHAR);
  846. X            PUTCH(Column+1,Row,NO_CHAR);
  847. X            PUTCH(Column-2,Row,R_CHAR);
  848. X            PUTCH(Column,Row-1,R_CHAR);
  849. X            Column -=1;
  850. X            }
  851. X        else goto beepout;
  852. X        goto out;
  853. X    case R_TYPE-3 : /* checked */
  854. X        if (IS_FREE(Column-2,Row-1) && IS_FREE(Column-1,Row) && 
  855. X            IS_FREE(Column-1,Row+1)) {
  856. X            PUTCH(Column,Row-1,NO_CHAR);
  857. X            PUTCH(Column,Row,NO_CHAR);
  858. X            PUTCH(Column,Row+1,NO_CHAR);
  859. X            PUTCH(Column-2,Row-1,R_CHAR);
  860. X            PUTCH(Column-1,Row,R_CHAR);
  861. X            PUTCH(Column-1,Row+1,R_CHAR);
  862. X            Column -=1;
  863. X            }
  864. X        else goto beepout;
  865. X        goto out;
  866. X
  867. X    /*  TAN PIECES  */
  868. X    case T_TYPE   :
  869. X    case T_TYPE-1 :
  870. X    case T_TYPE-2 :
  871. X    case T_TYPE-3 : /* checked */
  872. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column-1,Row+1)) {
  873. X            PUTCH(Column+1,Row,NO_CHAR);
  874. X            PUTCH(Column+1,Row+1,NO_CHAR);
  875. X            PUTCH(Column-1,Row,T_CHAR);
  876. X            PUTCH(Column-1,Row+1,T_CHAR);
  877. X            Column -=1;
  878. X            }
  879. X        else goto beepout;
  880. X        goto out;
  881. X
  882. X    /*  YELLOW PIECES  */
  883. X    case Y_TYPE   :
  884. X    case Y_TYPE-2 :  /* checked */
  885. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column-2,Row+1)) {
  886. X            PUTCH(Column+1,Row,NO_CHAR);
  887. X            PUTCH(Column,Row+1,NO_CHAR);
  888. X            PUTCH(Column-1,Row,Y_CHAR);
  889. X            PUTCH(Column-2,Row+1,Y_CHAR);
  890. X            Column -=1;
  891. X            }
  892. X        else goto beepout;
  893. X        goto out;
  894. X    case Y_TYPE-1 :
  895. X    case Y_TYPE-3 : /* checked */
  896. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-1,Row) && 
  897. X            IS_FREE(Column,Row+1)) {
  898. X            PUTCH(Column,Row-1,NO_CHAR);
  899. X            PUTCH(Column+1,Row,NO_CHAR);
  900. X            PUTCH(Column+1,Row+1,NO_CHAR);
  901. X            PUTCH(Column-1,Row-1,Y_CHAR);
  902. X            PUTCH(Column-1,Row,Y_CHAR);
  903. X            PUTCH(Column,Row+1,Y_CHAR);
  904. X            Column -=1;
  905. X            }
  906. X        else goto beepout;
  907. X        goto out;
  908. X
  909. X    /*  GREEN PIECES  */
  910. X    case G_TYPE   :
  911. X    case G_TYPE-2 : /* checked */
  912. X        if (IS_FREE(Column-2,Row) && IS_FREE(Column-1,Row+1)) {
  913. X            PUTCH(Column,Row,NO_CHAR);
  914. X            PUTCH(Column+1,Row+1,NO_CHAR);
  915. X            PUTCH(Column-2,Row,G_CHAR);
  916. X            PUTCH(Column-1,Row+1,G_CHAR);
  917. X            Column -=1;
  918. X            }
  919. X        else goto beepout;
  920. X        goto out;
  921. X    case G_TYPE-1 :
  922. X    case G_TYPE-3 : /* checked */
  923. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-2,Row) && 
  924. X            IS_FREE(Column-2,Row+1)) {
  925. X            PUTCH(Column,Row-1,NO_CHAR);
  926. X            PUTCH(Column,Row,NO_CHAR);
  927. X            PUTCH(Column-1,Row+1,NO_CHAR);
  928. X            PUTCH(Column-1,Row-1,G_CHAR);
  929. X            PUTCH(Column-2,Row,G_CHAR);
  930. X            PUTCH(Column-2,Row+1,G_CHAR);
  931. X            Column -=1;
  932. X            }
  933. X        else goto beepout;
  934. X        goto out;
  935. X
  936. X    /*  BLUE PIECES  */
  937. X    case B_TYPE   : /* checked */
  938. X        if (IS_FREE(Column-2,Row) && IS_FREE(Column,Row+1)) {
  939. X            PUTCH(Column+1,Row,NO_CHAR);
  940. X            PUTCH(Column+1,Row+1,NO_CHAR);
  941. X            PUTCH(Column-2,Row,B_CHAR);
  942. X            PUTCH(Column,Row+1,B_CHAR);
  943. X            Column -=1;
  944. X            }
  945. X        else goto beepout;
  946. X        goto out;
  947. X    case B_TYPE-1 : /* checked */
  948. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-1,Row) && 
  949. X            IS_FREE(Column-1,Row+1)) {
  950. X            PUTCH(Column+1,Row-1,NO_CHAR);
  951. X            PUTCH(Column,Row,NO_CHAR);
  952. X            PUTCH(Column,Row+1,NO_CHAR);
  953. X            PUTCH(Column-1,Row-1,B_CHAR);
  954. X            PUTCH(Column-1,Row,B_CHAR);
  955. X            PUTCH(Column-1,Row+1,B_CHAR);
  956. X            Column -=1;
  957. X            }
  958. X        else goto beepout;
  959. X        goto out;
  960. X    case B_TYPE-2 : /* checked */
  961. X        if (IS_FREE(Column-2,Row-1) && IS_FREE(Column-2,Row)) {
  962. X            PUTCH(Column-1,Row-1,NO_CHAR);
  963. X            PUTCH(Column+1,Row,NO_CHAR);
  964. X            PUTCH(Column-2,Row-1,B_CHAR);
  965. X            PUTCH(Column-2,Row,B_CHAR);
  966. X            Column -=1;
  967. X            }
  968. X        else goto beepout;
  969. X        goto out;
  970. X    case B_TYPE-3 : /* checked */
  971. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-1,Row) && 
  972. X            IS_FREE(Column-2,Row+1)) {
  973. X            PUTCH(Column,Row-1,NO_CHAR);
  974. X            PUTCH(Column,Row,NO_CHAR);
  975. X            PUTCH(Column,Row+1,NO_CHAR);
  976. X            PUTCH(Column-1,Row-1,B_CHAR);
  977. X            PUTCH(Column-1,Row,B_CHAR);
  978. X            PUTCH(Column-2,Row+1,B_CHAR);
  979. X            Column -=1;
  980. X            }
  981. X        else goto beepout;
  982. X        goto out;
  983. X
  984. X    /*  VIOLET PIECES  */
  985. X    case V_TYPE   :
  986. X    case V_TYPE-2 : /* checked */
  987. X        if (IS_FREE(Column-2,Row)) {
  988. X            PUTCH(Column+2,Row,NO_CHAR);
  989. X            PUTCH(Column-2,Row,V_CHAR);
  990. X            Column -=1;
  991. X            }
  992. X        else goto beepout;
  993. X        goto out;
  994. X    case V_TYPE-1 :
  995. X    case V_TYPE-3 : /* checked */
  996. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-1,Row) && 
  997. X            IS_FREE(Column-1,Row+1) && IS_FREE(Column-1,Row+2)) {
  998. X            PUTCH(Column,Row-1,NO_CHAR);
  999. X            PUTCH(Column,Row,NO_CHAR);
  1000. X            PUTCH(Column,Row+1,NO_CHAR);
  1001. X            PUTCH(Column,Row+2,NO_CHAR);
  1002. X            PUTCH(Column-1,Row-1,V_CHAR);
  1003. X            PUTCH(Column-1,Row,V_CHAR);
  1004. X            PUTCH(Column-1,Row+1,V_CHAR);
  1005. X            PUTCH(Column-1,Row+2,V_CHAR);
  1006. X            Column -=1;
  1007. X            }
  1008. X        else goto beepout;
  1009. X        goto out;
  1010. X    default : 
  1011. X        printf("illegal piece Type=%d!!\n",Type); 
  1012. X        exit();
  1013. X    }
  1014. Xbeepout:
  1015. X    if (Beep) beep();
  1016. Xout:
  1017. X    refresh();
  1018. X}
  1019. X
  1020. END_OF_FILE
  1021. if test 6741 -ne `wc -c <'MoveL.c'`; then
  1022.     echo shar: \"'MoveL.c'\" unpacked with wrong size!
  1023. fi
  1024. # end of 'MoveL.c'
  1025. fi
  1026. if test -f 'MoveR.c' -a "${1}" != "-c" ; then 
  1027.   echo shar: Will not clobber existing file \"'MoveR.c'\"
  1028. else
  1029. echo shar: Extracting \"'MoveR.c'\" \(6659 characters\)
  1030. sed "s/^X//" >'MoveR.c' <<'END_OF_FILE'
  1031. X
  1032. X#include <curses.h>
  1033. X#include "tet.h"
  1034. X/*********************************************************************/
  1035. X/* Switch on type of piece, find out if I can move right */
  1036. X/* If so, then do it */
  1037. X/*********************************************************************/
  1038. XMoveRight()
  1039. X{
  1040. Xswitch (Type) {
  1041. X
  1042. X    /*  WHITE PIECES  */
  1043. X    case W_TYPE   : /*  */
  1044. X        if (IS_FREE(Column+2,Row) && IS_FREE(Column+1,Row+1)) {
  1045. X            PUTCH(Column-1,Row,NO_CHAR);
  1046. X            PUTCH(Column,Row+1,NO_CHAR);
  1047. X            PUTCH(Column+2,Row,W_CHAR);
  1048. X            PUTCH(Column+1,Row+1,W_CHAR);
  1049. X            Column +=1;
  1050. X            }
  1051. X        else goto beepout;
  1052. X        goto out;
  1053. X    case W_TYPE-1 :  /*  */
  1054. X        if (IS_FREE(Column+1,Row-1) && IS_FREE(Column+2,Row) && 
  1055. X            IS_FREE(Column+1,Row+1)) {
  1056. X            PUTCH(Column,Row-1,NO_CHAR);
  1057. X            PUTCH(Column,Row,NO_CHAR);
  1058. X            PUTCH(Column,Row+1,NO_CHAR);
  1059. X            PUTCH(Column+1,Row-1,W_CHAR);
  1060. X            PUTCH(Column+2,Row,W_CHAR);
  1061. X            PUTCH(Column+1,Row+1,W_CHAR);
  1062. X            Column +=1;
  1063. X            }
  1064. X        else goto beepout;
  1065. X        goto out;
  1066. X    case W_TYPE-2 :  /*  */
  1067. X        if (IS_FREE(Column+2,Row) && IS_FREE(Column+1,Row-1)) {
  1068. X            PUTCH(Column-1,Row,NO_CHAR);
  1069. X            PUTCH(Column,Row-1,NO_CHAR);
  1070. X            PUTCH(Column+2,Row,W_CHAR);
  1071. X            PUTCH(Column+1,Row-1,W_CHAR);
  1072. X            Column +=1;
  1073. X            }
  1074. X        else goto beepout;
  1075. X        goto out;
  1076. X    case W_TYPE-3 :  /*  */
  1077. X        if (IS_FREE(Column+1,Row-1) && IS_FREE(Column+1,Row) && 
  1078. X            IS_FREE(Column+1,Row+1)) {
  1079. X            PUTCH(Column,Row-1,NO_CHAR);
  1080. X            PUTCH(Column-1,Row,NO_CHAR);
  1081. X            PUTCH(Column,Row+1,NO_CHAR);
  1082. X            PUTCH(Column+1,Row-1,W_CHAR);
  1083. X            PUTCH(Column+1,Row,W_CHAR);
  1084. X            PUTCH(Column+1,Row+1,W_CHAR);
  1085. X            Column +=1;
  1086. X            }
  1087. X        else goto beepout;
  1088. X        goto out;
  1089. X
  1090. X    /*  RED PIECES  */
  1091. X    case R_TYPE   : /*  */
  1092. X        if (IS_FREE(Column,Row+1) && IS_FREE(Column+2,Row)) {
  1093. X            PUTCH(Column-1,Row,NO_CHAR);
  1094. X            PUTCH(Column-1,Row+1,NO_CHAR);
  1095. X            PUTCH(Column+2,Row,R_CHAR);
  1096. X            PUTCH(Column,Row+1,R_CHAR);
  1097. X            Column +=1;
  1098. X            }
  1099. X        else goto beepout;
  1100. X        goto out;
  1101. X    case R_TYPE-1 : /*  */
  1102. X        if (IS_FREE(Column+1,Row-1) && IS_FREE(Column+1,Row) && 
  1103. X            IS_FREE(Column+2,Row+1)) {
  1104. X            PUTCH(Column,Row-1,NO_CHAR);
  1105. X            PUTCH(Column,Row,NO_CHAR);
  1106. X            PUTCH(Column,Row+1,NO_CHAR);
  1107. X            PUTCH(Column+1,Row-1,R_CHAR);
  1108. X            PUTCH(Column+1,Row,R_CHAR);
  1109. X            PUTCH(Column+2,Row+1,R_CHAR);
  1110. X            Column +=1;
  1111. X            }
  1112. X        else goto beepout;
  1113. X        goto out;
  1114. X    case R_TYPE-2 : /*  */
  1115. X        if (IS_FREE(Column+2,Row-1) && IS_FREE(Column+2,Row)) {
  1116. X            PUTCH(Column-1,Row,NO_CHAR);
  1117. X            PUTCH(Column+1,Row-1,NO_CHAR);
  1118. X            PUTCH(Column+2,Row,R_CHAR);
  1119. X            PUTCH(Column+2,Row-1,R_CHAR);
  1120. X            Column +=1;
  1121. X            }
  1122. X        else goto beepout;
  1123. X        goto out;
  1124. X    case R_TYPE-3 : /*  */
  1125. X        if (IS_FREE(Column+1,Row-1) && IS_FREE(Column+1,Row) && 
  1126. X            IS_FREE(Column+1,Row+1)) {
  1127. X            PUTCH(Column-1,Row-1,NO_CHAR);
  1128. X            PUTCH(Column,Row,NO_CHAR);
  1129. X            PUTCH(Column,Row+1,NO_CHAR);
  1130. X            PUTCH(Column+1,Row-1,R_CHAR);
  1131. X            PUTCH(Column+1,Row,R_CHAR);
  1132. X            PUTCH(Column+1,Row+1,R_CHAR);
  1133. X            Column +=1;
  1134. X            }
  1135. X        else goto beepout;
  1136. X        goto out;
  1137. X
  1138. X    /*  TAN PIECES  */
  1139. X    case T_TYPE   :
  1140. X    case T_TYPE-1 :
  1141. X    case T_TYPE-2 :
  1142. X    case T_TYPE-3 : /*  */
  1143. X        if (IS_FREE(Column+2,Row) && IS_FREE(Column+2,Row+1)) {
  1144. X            PUTCH(Column,Row,NO_CHAR);
  1145. X            PUTCH(Column,Row+1,NO_CHAR);
  1146. X            PUTCH(Column+2,Row,T_CHAR);
  1147. X            PUTCH(Column+2,Row+1,T_CHAR);
  1148. X            Column +=1;
  1149. X            }
  1150. X        else goto beepout;
  1151. X        goto out;
  1152. X
  1153. X    /*  YELLOW PIECES  */
  1154. X    case Y_TYPE   :
  1155. X    case Y_TYPE-2 : /* checked */
  1156. X        if (IS_FREE(Column+2,Row) && IS_FREE(Column+1,Row+1)) {
  1157. X            PUTCH(Column,Row,NO_CHAR);
  1158. X            PUTCH(Column-1,Row+1,NO_CHAR);
  1159. X            PUTCH(Column+2,Row,Y_CHAR);
  1160. X            PUTCH(Column+1,Row+1,Y_CHAR);
  1161. X            Column +=1;
  1162. X            }
  1163. X        else goto beepout;
  1164. X        goto out;
  1165. X    case Y_TYPE-1 :
  1166. X    case Y_TYPE-3 : /*  */
  1167. X        if (IS_FREE(Column+1,Row-1) && IS_FREE(Column+2,Row) && 
  1168. X            IS_FREE(Column+2,Row+1)) {
  1169. X            PUTCH(Column,Row-1,NO_CHAR);
  1170. X            PUTCH(Column,Row,NO_CHAR);
  1171. X            PUTCH(Column+1,Row+1,NO_CHAR);
  1172. X            PUTCH(Column+1,Row-1,Y_CHAR);
  1173. X            PUTCH(Column+2,Row,Y_CHAR);
  1174. X            PUTCH(Column+2,Row+1,Y_CHAR);
  1175. X            Column +=1;
  1176. X            }
  1177. X        else goto beepout;
  1178. X        goto out;
  1179. X
  1180. X    /*  GREEN PIECES  */
  1181. X    case G_TYPE   :
  1182. X    case G_TYPE-2 : /* checked */
  1183. X        if (IS_FREE(Column+1,Row) && IS_FREE(Column+2,Row+1)) {
  1184. X            PUTCH(Column-1,Row,NO_CHAR);
  1185. X            PUTCH(Column,Row+1,NO_CHAR);
  1186. X            PUTCH(Column+1,Row,G_CHAR);
  1187. X            PUTCH(Column+2,Row+1,G_CHAR);
  1188. X            Column +=1;
  1189. X            }
  1190. X        else goto beepout;
  1191. X        goto out;
  1192. X    case G_TYPE-1 :
  1193. X    case G_TYPE-3 : /*  */
  1194. X        if (IS_FREE(Column+1,Row-1) && IS_FREE(Column+1,Row) && 
  1195. X            IS_FREE(Column,Row+1)) {
  1196. X            PUTCH(Column,Row-1,NO_CHAR);
  1197. X            PUTCH(Column-1,Row,NO_CHAR);
  1198. X            PUTCH(Column-1,Row+1,NO_CHAR);
  1199. X            PUTCH(Column+1,Row-1,G_CHAR);
  1200. X            PUTCH(Column+1,Row,G_CHAR);
  1201. X            PUTCH(Column,Row+1,G_CHAR);
  1202. X            Column +=1;
  1203. X            }
  1204. X        else goto beepout;
  1205. X        goto out;
  1206. X
  1207. X    /*  BLUE PIECES  */
  1208. X    case B_TYPE   : /* checked */
  1209. X        if (IS_FREE(Column+2,Row) && IS_FREE(Column+2,Row+1)) {
  1210. X            PUTCH(Column-1,Row,NO_CHAR);
  1211. X            PUTCH(Column+1,Row+1,NO_CHAR);
  1212. X            PUTCH(Column+2,Row,B_CHAR);
  1213. X            PUTCH(Column+2,Row+1,B_CHAR);
  1214. X            Column +=1;
  1215. X            }
  1216. X        else goto beepout;
  1217. X        goto out;
  1218. X    case B_TYPE-1 : /* checked */
  1219. X        if (IS_FREE(Column+2,Row-1) && IS_FREE(Column+1,Row) && 
  1220. X            IS_FREE(Column+1,Row+1)) {
  1221. X            PUTCH(Column,Row-1,NO_CHAR);
  1222. X            PUTCH(Column,Row,NO_CHAR);
  1223. X            PUTCH(Column,Row+1,NO_CHAR);
  1224. X            PUTCH(Column+2,Row-1,B_CHAR);
  1225. X            PUTCH(Column+1,Row,B_CHAR);
  1226. X            PUTCH(Column+1,Row+1,B_CHAR);
  1227. X            Column +=1;
  1228. X            }
  1229. X        else goto beepout;
  1230. X        goto out;
  1231. X    case B_TYPE-2 : /* checked */
  1232. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column+2,Row)) {
  1233. X            PUTCH(Column-1,Row-1,NO_CHAR);
  1234. X            PUTCH(Column-1,Row,NO_CHAR);
  1235. X            PUTCH(Column,Row-1,B_CHAR);
  1236. X            PUTCH(Column+2,Row,B_CHAR);
  1237. X            Column +=1;
  1238. X            }
  1239. X        else goto beepout;
  1240. X        goto out;
  1241. X    case B_TYPE-3 : /* checked */
  1242. X        if (IS_FREE(Column+1,Row-1) && IS_FREE(Column+1,Row) && 
  1243. X            IS_FREE(Column+1,Row+1)) {
  1244. X            PUTCH(Column,Row-1,NO_CHAR);
  1245. X            PUTCH(Column,Row,NO_CHAR);
  1246. X            PUTCH(Column-1,Row+1,NO_CHAR);
  1247. X            PUTCH(Column+1,Row-1,B_CHAR);
  1248. X            PUTCH(Column+1,Row,B_CHAR);
  1249. X            PUTCH(Column+1,Row+1,B_CHAR);
  1250. X            Column +=1;
  1251. X            }
  1252. X        else goto beepout;
  1253. X        goto out;
  1254. X
  1255. X    /*  VIOLET PIECES  */
  1256. X    case V_TYPE   :
  1257. X    case V_TYPE-2 : /* checked */
  1258. X        if (IS_FREE(Column+3,Row)) {
  1259. X            PUTCH(Column-1,Row,NO_CHAR);
  1260. X            PUTCH(Column+3,Row,V_CHAR);
  1261. X            Column +=1;
  1262. X            }
  1263. X        else goto beepout;
  1264. X        goto out;
  1265. X    case V_TYPE-1 :
  1266. X    case V_TYPE-3 : /* checked */
  1267. X        if (IS_FREE(Column+1,Row-1) && IS_FREE(Column+1,Row) && 
  1268. X            IS_FREE(Column+1,Row+1) && IS_FREE(Column+1,Row+2)) {
  1269. X            PUTCH(Column,Row-1,NO_CHAR);
  1270. X            PUTCH(Column,Row,NO_CHAR);
  1271. X            PUTCH(Column,Row+1,NO_CHAR);
  1272. X            PUTCH(Column,Row+2,NO_CHAR);
  1273. X            PUTCH(Column+1,Row-1,V_CHAR);
  1274. X            PUTCH(Column+1,Row,V_CHAR);
  1275. X            PUTCH(Column+1,Row+1,V_CHAR);
  1276. X            PUTCH(Column+1,Row+2,V_CHAR);
  1277. X            Column +=1;
  1278. X            }
  1279. X        else goto beepout;
  1280. X        goto out;
  1281. X    default : 
  1282. X        printf("illegal piece Type=%d!!\n",Type);
  1283. X        exit();
  1284. X    }
  1285. Xbeepout:
  1286. X    if (Beep) beep();
  1287. Xout:
  1288. X    refresh();
  1289. X}
  1290. X
  1291. END_OF_FILE
  1292. if test 6659 -ne `wc -c <'MoveR.c'`; then
  1293.     echo shar: \"'MoveR.c'\" unpacked with wrong size!
  1294. fi
  1295. # end of 'MoveR.c'
  1296. fi
  1297. if test -f 'NewP.c' -a "${1}" != "-c" ; then 
  1298.   echo shar: Will not clobber existing file \"'NewP.c'\"
  1299. else
  1300. echo shar: Extracting \"'NewP.c'\" \(3103 characters\)
  1301. sed "s/^X//" >'NewP.c' <<'END_OF_FILE'
  1302. X
  1303. X#include <curses.h>
  1304. X#include "tet.h"
  1305. X/*********************************************************************/
  1306. X/* A new piece is created on the game board if possible */
  1307. X/* returns 0 if unable to do it */
  1308. X/*********************************************************************/
  1309. XNewPiece()
  1310. X{    
  1311. XFallingDown = 0;            /* true when fall key is pressed */
  1312. XType = ((int)(mrand48() % 4) + 4) * 4;    /* random number 4 8 16 20 24 or 28 */
  1313. X/* printf("DEBUG:NewPiece Type = %d\n",Type); */
  1314. X
  1315. Xswitch (Type) {
  1316. X    case W_TYPE : /* checked  */
  1317. X        if (IS_FREE(STARTCOL-1,STARTROW) && IS_FREE(STARTCOL,STARTROW) &&
  1318. X        IS_FREE(STARTCOL+1,STARTROW) && IS_FREE(STARTCOL,STARTROW+1)) {
  1319. X        PUTCH(STARTCOL-1,STARTROW,W_CHAR);
  1320. X        PUTCH(STARTCOL,STARTROW,W_CHAR);
  1321. X        PUTCH(STARTCOL+1,STARTROW,W_CHAR);
  1322. X        PUTCH(STARTCOL,STARTROW+1,W_CHAR);
  1323. X        }
  1324. X        else {
  1325. X    return(0);
  1326. X    }
  1327. X    break;
  1328. X    case R_TYPE : /* checked */
  1329. X        if (IS_FREE(STARTCOL-1,STARTROW) && IS_FREE(STARTCOL,STARTROW) &&
  1330. X           IS_FREE(STARTCOL+1,STARTROW) && IS_FREE(STARTCOL-1,STARTROW+1)) {
  1331. X        PUTCH(STARTCOL-1,STARTROW,R_CHAR);
  1332. X        PUTCH(STARTCOL,STARTROW,R_CHAR);
  1333. X        PUTCH(STARTCOL+1,STARTROW,R_CHAR);
  1334. X        PUTCH(STARTCOL-1,STARTROW+1,R_CHAR);
  1335. X        }
  1336. X        else return(0);
  1337. X    break;
  1338. X    case T_TYPE : /* checked */
  1339. X        if (IS_FREE(STARTCOL,STARTROW) && IS_FREE(STARTCOL,STARTROW+1) &&
  1340. X           IS_FREE(STARTCOL+1,STARTROW) && IS_FREE(STARTCOL+1,STARTROW+1)) {
  1341. X        PUTCH(STARTCOL,STARTROW,T_CHAR);
  1342. X        PUTCH(STARTCOL,STARTROW+1,T_CHAR);
  1343. X        PUTCH(STARTCOL+1,STARTROW,T_CHAR);
  1344. X        PUTCH(STARTCOL+1,STARTROW+1,T_CHAR);
  1345. X        }
  1346. X        else return(0);
  1347. X    break;
  1348. X    case Y_TYPE : /* checked */
  1349. X       if (IS_FREE(STARTCOL-1,STARTROW+1) && IS_FREE(STARTCOL,STARTROW+1) &&
  1350. X        IS_FREE(STARTCOL,STARTROW) && IS_FREE(STARTCOL+1,STARTROW)) {
  1351. X        PUTCH(STARTCOL-1,STARTROW+1,Y_CHAR);
  1352. X        PUTCH(STARTCOL,STARTROW+1,Y_CHAR);
  1353. X        PUTCH(STARTCOL,STARTROW,Y_CHAR);
  1354. X        PUTCH(STARTCOL+1,STARTROW,Y_CHAR);
  1355. X        }
  1356. X        else return(0);
  1357. X    break;
  1358. X    case G_TYPE : { /* checked */
  1359. X        if (IS_FREE(STARTCOL-1,STARTROW) && IS_FREE(STARTCOL,STARTROW) &&
  1360. X           IS_FREE(STARTCOL,STARTROW+1) && IS_FREE(STARTCOL+1,STARTROW+1)) {
  1361. X        PUTCH(STARTCOL-1,STARTROW,G_CHAR);
  1362. X        PUTCH(STARTCOL,STARTROW,G_CHAR);
  1363. X        PUTCH(STARTCOL,STARTROW+1,G_CHAR);
  1364. X        PUTCH(STARTCOL+1,STARTROW+1,G_CHAR);
  1365. X        }
  1366. X        else return(0);
  1367. X    break; }
  1368. X    case B_TYPE : /* checked */
  1369. X        if (IS_FREE(STARTCOL-1,STARTROW) && IS_FREE(STARTCOL,STARTROW) &&
  1370. X           IS_FREE(STARTCOL+1,STARTROW) && IS_FREE(STARTCOL+1,STARTROW+1)) {
  1371. X        PUTCH(STARTCOL-1,STARTROW,B_CHAR);
  1372. X        PUTCH(STARTCOL,STARTROW,B_CHAR);
  1373. X        PUTCH(STARTCOL+1,STARTROW,B_CHAR);
  1374. X        PUTCH(STARTCOL+1,STARTROW+1,B_CHAR);
  1375. X        }
  1376. X        else return(0);
  1377. X    break;
  1378. X    case V_TYPE : /* checked */
  1379. X        if (IS_FREE(STARTCOL-1,STARTROW) && IS_FREE(STARTCOL,STARTROW) &&
  1380. X        IS_FREE(STARTCOL+1,STARTROW) && IS_FREE(STARTCOL+2,STARTROW)) {
  1381. X        PUTCH(STARTCOL-1,STARTROW,V_CHAR);
  1382. X        PUTCH(STARTCOL,STARTROW,V_CHAR);
  1383. X        PUTCH(STARTCOL+1,STARTROW,V_CHAR);
  1384. X        PUTCH(STARTCOL+2,STARTROW,V_CHAR);
  1385. X        }
  1386. X        else return(0);
  1387. X    break;
  1388. X    default : printf("illegal piece Type=%d!!\n",Type); exit();
  1389. X    }
  1390. Xrefresh();
  1391. XRow=STARTROW; Column=STARTCOL;    /* all pieces start at same point */
  1392. X}
  1393. END_OF_FILE
  1394. if test 3103 -ne `wc -c <'NewP.c'`; then
  1395.     echo shar: \"'NewP.c'\" unpacked with wrong size!
  1396. fi
  1397. # end of 'NewP.c'
  1398. fi
  1399. if test -f 'Rotate.c' -a "${1}" != "-c" ; then 
  1400.   echo shar: Will not clobber existing file \"'Rotate.c'\"
  1401. else
  1402. echo shar: Extracting \"'Rotate.c'\" \(6209 characters\)
  1403. sed "s/^X//" >'Rotate.c' <<'END_OF_FILE'
  1404. X
  1405. X#include <curses.h>
  1406. X#include "tet.h"
  1407. X/*********************************************************************/
  1408. X/* Switch on type of piece, find out if I can rotate */
  1409. X/* If so, then do it */
  1410. X/*********************************************************************/
  1411. XRotate()
  1412. X{
  1413. Xswitch (Type) {
  1414. X    /*  WHITE PIECES  */
  1415. X    case W_TYPE   :  /* checked */
  1416. X        if (IS_FREE(Column,Row-1)) {
  1417. X            PUTCH(Column-1,Row,NO_CHAR);
  1418. X            PUTCH(Column,Row-1,W_CHAR);
  1419. X            Type--;
  1420. X            }
  1421. X        else goto beepout;
  1422. X        goto out;
  1423. X    case W_TYPE-1 :  /* checked */
  1424. X        if (IS_FREE(Column-1,Row)) {
  1425. X            PUTCH(Column,Row+1,NO_CHAR);
  1426. X            PUTCH(Column-1,Row,W_CHAR);
  1427. X            Type--;
  1428. X            }
  1429. X        else goto beepout;
  1430. X        goto out;
  1431. X    case W_TYPE-2 :  /* checked */
  1432. X        if (IS_FREE(Column,Row+1)) {
  1433. X            PUTCH(Column+1,Row,NO_CHAR);
  1434. X            PUTCH(Column,Row+1,W_CHAR);
  1435. X            Type--;
  1436. X            }
  1437. X        else goto beepout;
  1438. X        goto out;
  1439. X    case W_TYPE-3 :  /* checked */
  1440. X        if (IS_FREE(Column+1,Row)) {
  1441. X            PUTCH(Column,Row-1,NO_CHAR);
  1442. X            PUTCH(Column+1,Row,W_CHAR);
  1443. X            Type = W_TYPE;
  1444. X            }
  1445. X        else goto beepout;
  1446. X        goto out;
  1447. X
  1448. X    /*  RED PIECES  */
  1449. X    case R_TYPE   : /* checked */
  1450. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column,Row+1) && 
  1451. X            IS_FREE(Column+1,Row+1)) {
  1452. X            PUTCH(Column-1,Row,NO_CHAR);
  1453. X            PUTCH(Column-1,Row+1,NO_CHAR);
  1454. X            PUTCH(Column+1,Row,NO_CHAR);
  1455. X            PUTCH(Column,Row-1,R_CHAR);
  1456. X            PUTCH(Column,Row+1,R_CHAR);
  1457. X            PUTCH(Column+1,Row+1,R_CHAR);
  1458. X            Type--;
  1459. X            }
  1460. X        else goto beepout;
  1461. X        goto out;
  1462. X    case R_TYPE-1 : /* checked */
  1463. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column+1,Row-1) && 
  1464. X            IS_FREE(Column+1,Row)) {
  1465. X            PUTCH(Column,Row-1,NO_CHAR);
  1466. X            PUTCH(Column,Row+1,NO_CHAR);
  1467. X            PUTCH(Column+1,Row+1,NO_CHAR);
  1468. X            PUTCH(Column-1,Row,R_CHAR);
  1469. X            PUTCH(Column+1,Row-1,R_CHAR);
  1470. X            PUTCH(Column+1,Row,R_CHAR);
  1471. X            Type--;
  1472. X            }
  1473. X        else goto beepout;
  1474. X        goto out;
  1475. X    case R_TYPE-2 : /* checked  */
  1476. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column,Row-1) && 
  1477. X            IS_FREE(Column,Row+1)) {
  1478. X            PUTCH(Column-1,Row,NO_CHAR);
  1479. X            PUTCH(Column+1,Row-1,NO_CHAR);
  1480. X            PUTCH(Column+1,Row,NO_CHAR);
  1481. X            PUTCH(Column-1,Row-1,R_CHAR);
  1482. X            PUTCH(Column,Row-1,R_CHAR);
  1483. X            PUTCH(Column,Row+1,R_CHAR);
  1484. X            Type--;
  1485. X            }
  1486. X        else goto beepout;
  1487. X        goto out;
  1488. X    case R_TYPE-3 : /* checked */
  1489. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column-1,Row+1) && 
  1490. X            IS_FREE(Column+1,Row)) {
  1491. X            PUTCH(Column-1,Row-1,NO_CHAR);
  1492. X            PUTCH(Column,Row-1,NO_CHAR);
  1493. X            PUTCH(Column,Row+1,NO_CHAR);
  1494. X            PUTCH(Column-1,Row,R_CHAR);
  1495. X            PUTCH(Column-1,Row+1,R_CHAR);
  1496. X            PUTCH(Column+1,Row,R_CHAR);
  1497. X            Type = R_TYPE;
  1498. X            }
  1499. X        else goto beepout;
  1500. X        goto out;
  1501. X
  1502. X    /*  TAN PIECES  */
  1503. X    case T_TYPE   :
  1504. X    case T_TYPE-1 :
  1505. X    case T_TYPE-2 :
  1506. X    case T_TYPE-3 : goto out;
  1507. X
  1508. X    /*  YELLOW PIECES  */
  1509. X    case Y_TYPE   :
  1510. X    case Y_TYPE-2 :  /* checked */
  1511. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column+1,Row+1)) {
  1512. X            PUTCH(Column-1,Row+1,NO_CHAR);
  1513. X            PUTCH(Column,Row+1,NO_CHAR);
  1514. X            PUTCH(Column,Row-1,Y_CHAR);
  1515. X            PUTCH(Column+1,Row+1,Y_CHAR);
  1516. X            Type--;
  1517. X            }
  1518. X        else goto beepout;
  1519. X        goto out;
  1520. X    case Y_TYPE-1 :
  1521. X    case Y_TYPE-3 : /* checked */
  1522. X        if (IS_FREE(Column-1,Row+1) && IS_FREE(Column,Row+1)) {
  1523. X            PUTCH(Column,Row-1,NO_CHAR);
  1524. X            PUTCH(Column+1,Row+1,NO_CHAR);
  1525. X            PUTCH(Column-1,Row+1,Y_CHAR);
  1526. X            PUTCH(Column,Row+1,Y_CHAR);
  1527. X            Type = Y_TYPE;
  1528. X            }
  1529. X        else goto beepout;
  1530. X        goto out;
  1531. X
  1532. X    /*  GREEN PIECES  */
  1533. X    case G_TYPE   :
  1534. X    case G_TYPE-2 : /* checked */
  1535. X        if (IS_FREE(Column-1,Row+1) && IS_FREE(Column,Row-1)) {
  1536. X            PUTCH(Column,Row+1,NO_CHAR);
  1537. X            PUTCH(Column+1,Row+1,NO_CHAR);
  1538. X            PUTCH(Column-1,Row+1,G_CHAR);
  1539. X            PUTCH(Column,Row-1,G_CHAR);
  1540. X            Type--;
  1541. X            }
  1542. X        else goto beepout;
  1543. X        goto out;
  1544. X    case G_TYPE-1 :
  1545. X    case G_TYPE-3 : /* checked */
  1546. X        if (IS_FREE(Column,Row+1) && IS_FREE(Column+1,Row+1)) {
  1547. X            PUTCH(Column-1,Row+1,NO_CHAR);
  1548. X            PUTCH(Column,Row-1,NO_CHAR);
  1549. X            PUTCH(Column,Row+1,G_CHAR);
  1550. X            PUTCH(Column+1,Row+1,G_CHAR);
  1551. X            Type = G_TYPE;
  1552. X            }
  1553. X        else goto beepout;
  1554. X        goto out;
  1555. X
  1556. X
  1557. X    /*  BLUE PIECES  */
  1558. X    case B_TYPE   : /* checked */
  1559. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column,Row+1) && 
  1560. X            IS_FREE(Column+1,Row-1)) {
  1561. X            PUTCH(Column-1,Row,NO_CHAR);
  1562. X            PUTCH(Column+1,Row,NO_CHAR);
  1563. X            PUTCH(Column+1,Row+1,NO_CHAR);
  1564. X            PUTCH(Column,Row-1,B_CHAR);
  1565. X            PUTCH(Column,Row+1,B_CHAR);
  1566. X            PUTCH(Column+1,Row-1,B_CHAR);
  1567. X            Type--;
  1568. X            }
  1569. X        else goto beepout;
  1570. X        goto out;
  1571. X    case B_TYPE-1 : /* checked */
  1572. X        if (IS_FREE(Column-1,Row-1) && IS_FREE(Column-1,Row) && 
  1573. X            IS_FREE(Column+1,Row)) {
  1574. X            PUTCH(Column,Row-1,NO_CHAR);
  1575. X            PUTCH(Column,Row+1,NO_CHAR);
  1576. X            PUTCH(Column+1,Row-1,NO_CHAR);
  1577. X            PUTCH(Column-1,Row-1,B_CHAR);
  1578. X            PUTCH(Column-1,Row,B_CHAR);
  1579. X            PUTCH(Column+1,Row,B_CHAR);
  1580. X            Type--;
  1581. X            }
  1582. X        else goto beepout;
  1583. X        goto out;
  1584. X    case B_TYPE-2 : /* checked  */
  1585. X        if (IS_FREE(Column-1,Row+1) && IS_FREE(Column,Row-1) && 
  1586. X            IS_FREE(Column,Row+1)) {
  1587. X            PUTCH(Column-1,Row-1,NO_CHAR);
  1588. X            PUTCH(Column-1,Row,NO_CHAR);
  1589. X            PUTCH(Column+1,Row,NO_CHAR);
  1590. X            PUTCH(Column-1,Row+1,B_CHAR);
  1591. X            PUTCH(Column,Row-1,B_CHAR);
  1592. X            PUTCH(Column,Row+1,B_CHAR);
  1593. X            Type--;
  1594. X            }
  1595. X        else goto beepout;
  1596. X        goto out;
  1597. X    case B_TYPE-3 : /* checked */
  1598. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column+1,Row) && 
  1599. X            IS_FREE(Column+1,Row+1)) {
  1600. X            PUTCH(Column-1,Row+1,NO_CHAR);
  1601. X            PUTCH(Column,Row-1,NO_CHAR);
  1602. X            PUTCH(Column,Row+1,NO_CHAR);
  1603. X            PUTCH(Column-1,Row,B_CHAR);
  1604. X            PUTCH(Column+1,Row,B_CHAR);
  1605. X            PUTCH(Column+1,Row+1,B_CHAR);
  1606. X            Type = B_TYPE;
  1607. X            }
  1608. X        else goto beepout;
  1609. X        goto out;
  1610. X
  1611. X    /*  VIOLET PIECES  */
  1612. X    case V_TYPE   :
  1613. X    case V_TYPE-2 : /* checked */
  1614. X        if (IS_FREE(Column,Row-1) && IS_FREE(Column,Row+1) && 
  1615. X            IS_FREE(Column,Row+2)) {
  1616. X            PUTCH(Column-1,Row,NO_CHAR);
  1617. X            PUTCH(Column+1,Row,NO_CHAR);
  1618. X            PUTCH(Column+2,Row,NO_CHAR);
  1619. X            PUTCH(Column,Row-1,V_CHAR);
  1620. X            PUTCH(Column,Row+1,V_CHAR);
  1621. X            PUTCH(Column,Row+2,V_CHAR);
  1622. X            Type--;
  1623. X            }
  1624. X        else goto beepout;
  1625. X        goto out;
  1626. X    case V_TYPE-1 :
  1627. X    case V_TYPE-3 : /* checked */
  1628. X        if (IS_FREE(Column-1,Row) && IS_FREE(Column+1,Row) && 
  1629. X            IS_FREE(Column+2,Row)) {
  1630. X            PUTCH(Column,Row-1,NO_CHAR);
  1631. X            PUTCH(Column,Row+1,NO_CHAR);
  1632. X            PUTCH(Column,Row+2,NO_CHAR);
  1633. X            PUTCH(Column-1,Row,V_CHAR);
  1634. X            PUTCH(Column,Row,V_CHAR);
  1635. X            PUTCH(Column+1,Row,V_CHAR);
  1636. X            PUTCH(Column+2,Row,V_CHAR);
  1637. X            Type = V_TYPE;
  1638. X            }
  1639. X        else goto beepout;
  1640. X        goto out;
  1641. X    default : 
  1642. X        printf("illegal piece Type=%d!!\n",Type); 
  1643. X        exit();
  1644. X    }
  1645. Xbeepout:
  1646. X    if (Beep) beep();
  1647. Xout:
  1648. X    refresh();
  1649. X}
  1650. X
  1651. END_OF_FILE
  1652. if test 6209 -ne `wc -c <'Rotate.c'`; then
  1653.     echo shar: \"'Rotate.c'\" unpacked with wrong size!
  1654. fi
  1655. # end of 'Rotate.c'
  1656. fi
  1657. if test -f 'tet.c' -a "${1}" != "-c" ; then 
  1658.   echo shar: Will not clobber existing file \"'tet.c'\"
  1659. else
  1660. echo shar: Extracting \"'tet.c'\" \(9501 characters\)
  1661. sed "s/^X//" >'tet.c' <<'END_OF_FILE'
  1662. X/* Tetrix by quentin */
  1663. X
  1664. X#include <signal.h>
  1665. X#include <sys/ioctl.h>
  1666. X#include <fcntl.h>
  1667. X#include <stdio.h>
  1668. X#include <curses.h>
  1669. X#include "tet.h"
  1670. X
  1671. X/********** Some global variable declarations ************/
  1672. Xint Type;        /* type specifies rotation, shape and color of blocks */
  1673. Xint Row;        /* Row of pivot point of block */
  1674. Xint Column;        /* Column of pivot point of block */
  1675. Xint Pause;        /* Time between movements this block */
  1676. Xint CurrentPause;    /* Time between movements per level */
  1677. Xint FallingDown;    /* True when space bar is pressed */
  1678. Xint Beep;
  1679. Xchar Key;        /* holds last key polled */
  1680. X
  1681. X#define SCORE_FILE    "/usr/tmp/.TetScores"
  1682. Xchar ScoreString[10];
  1683. Xstruct ScoreStruct {
  1684. X    char Name[10];
  1685. X    int Score;
  1686. X} High[10];
  1687. Xint ThisScore,HighsChanged;
  1688. X        
  1689. Xchar *ttyname();
  1690. Xchar combuf[2];
  1691. Xstruct termio origtty, tty;
  1692. Xchar Board[BOARD_WIDE][BOARD_HIGH];
  1693. Xchar Temp[BOARD_WIDE][BOARD_HIGH];    /* temp storage for TestRows */
  1694. X
  1695. X/* debug flash to screen */
  1696. X#define FLASHMSG(x)
  1697. X/*
  1698. X#define FLASHMSG(x)          { mvaddstr(23,0,"                "); \
  1699. X                mvaddstr(23,0,x); \
  1700. X                refresh(); }
  1701. X*/
  1702. X#define UPSCORE(x)    { ThisScore += x; \
  1703. X            sprintf((char *)ScoreString,"%-d",ThisScore); \
  1704. X            mvaddstr(1,46,ScoreString); }
  1705. X
  1706. X#define NULL_KEY    '\0'
  1707. X#define FALL_KEY    ' '
  1708. X#define RIGHT_KEY    'l'
  1709. X#define LEFT_KEY    'j'
  1710. X#define ROTATE_KEY    'k'
  1711. X#define L_RIGHT_KEY    'f'        /* for south paws */
  1712. X#define L_LEFT_KEY    's'
  1713. X#define L_ROTATE_KEY    'd'
  1714. X#define QUIT_KEY    'q'
  1715. X#define BEEP_KEY    'b'
  1716. X#define BOSS_KEY    '\033'
  1717. X#define PLAY_KEY    'p'
  1718. X#define SCORE_KEY    'h'
  1719. X#define MENU_KEY    'm'
  1720. X
  1721. X/**************************************************MAIN*****/
  1722. Xmain()
  1723. X{
  1724. X    Init();
  1725. X    for ( ; ; ) {
  1726. X        NewGame();
  1727. X        Play();
  1728. X        ScoreIt();
  1729. X        DrawScore();
  1730. X        }
  1731. X}
  1732. X
  1733. X/*************************************************************/
  1734. XInit()
  1735. X{
  1736. X    register char *ttnam, *p;
  1737. X    register int x,y,i,fd;
  1738. X    int timein;
  1739. X
  1740. X    time(&timein);        /* get start time */
  1741. X    srand48(timein);    /* start rand randomly */
  1742. X
  1743. X    ttnam = ttyname (0); 
  1744. X    close (0); 
  1745. X    open (ttnam, O_NDELAY);
  1746. X    /*
  1747. X     * setup raw mode, no echo
  1748. X     */
  1749. X    ioctl (0, TCGETA, &origtty);
  1750. X    ioctl (0, TCGETA, &tty);
  1751. X    tty.c_iflag &= 077;
  1752. X    tty.c_oflag &= 077700;
  1753. X    tty.c_lflag = 0201;
  1754. X    tty.c_cc[4] =  1;
  1755. X    ioctl (1, TCSETAW, &tty);
  1756. X    signal(SIGINT, SIG_IGN);
  1757. X    
  1758. X    Beep=0;
  1759. X    HighsChanged = 0;
  1760. X    ScoreIt();
  1761. X    initscr();
  1762. X    /* initilialize board to spaces */
  1763. X    for (x=0; x<BOARD_WIDE; x++) 
  1764. X        for (y=0; y<BOARD_HIGH; y++) 
  1765. X            PUTCH(x,y,NO_CHAR);
  1766. X    erase();
  1767. X    DrawMenu();
  1768. X    refresh();
  1769. X}
  1770. X
  1771. X/**************************************************************/
  1772. XNewGame()
  1773. X{
  1774. X    register int x,y;
  1775. X
  1776. X    CurrentPause=0;
  1777. X
  1778. X    while (!CurrentPause) {
  1779. X        GetKey();
  1780. X        switch (Key) {
  1781. X            case BEEP_KEY   : Beep = !Beep ;
  1782. X                      if (Beep) beep(); 
  1783. X                      break;
  1784. X            case SCORE_KEY  : DrawScore(); break;
  1785. X            case MENU_KEY    : DrawMenu(); break;
  1786. X            case BOSS_KEY    : Boss(); break;
  1787. X            case PLAY_KEY    : CurrentPause=150; break;
  1788. X            case QUIT_KEY   : Leave();
  1789. X            }
  1790. X    }
  1791. X    /* initilialize board to spaces */
  1792. X    for (x=0; x<BOARD_WIDE; x++) 
  1793. X        for (y=0; y<BOARD_HIGH; y++) 
  1794. X            PUTCH(x,y,NO_CHAR);
  1795. X    ThisScore=0;
  1796. X    mvaddstr(1,42,"|  ......  |");
  1797. X    UPSCORE(0);
  1798. X
  1799. X}
  1800. X
  1801. X/******************************************************************/
  1802. XDrawMenu()
  1803. X{
  1804. X    register int y;
  1805. X    erase(); 
  1806. X
  1807. X    /* draw score border */
  1808. X    mvaddstr(0,42,".----------.");
  1809. X    mvaddstr(1,42,"|  ......  |");
  1810. X    mvaddstr(2,42,"`----------'");
  1811. X    UPSCORE(0);
  1812. X
  1813. X    /* draw menu */
  1814. X    mvaddstr( 4,35,".---------------------------.");
  1815. X    mvaddstr( 5,35,"|                           |");
  1816. X    mvaddstr( 6,35,"|      ..   Menu   ..       |");
  1817. X    mvaddstr( 7,35,"|                           |");
  1818. X    mvaddstr( 8,35,"|   h     .... high scores  |");
  1819. X    mvaddstr( 9,35,"|   b     .... toggle beep  |");
  1820. X    mvaddstr(10,35,"|   p     .... play         |");
  1821. X    mvaddstr(11,35,"|   q     .... quit         |");
  1822. X    mvaddstr(12,35,"|                           |");
  1823. X    mvaddstr(13,35,"| s or j  .... move left    |");
  1824. X    mvaddstr(14,35,"| d or k  .... rotate piece |");
  1825. X    mvaddstr(15,35,"| f or l  .... move right   |");
  1826. X    mvaddstr(16,35,"|  spc    .... fall piece   |");
  1827. X    mvaddstr(17,35,"|  esc    .... pause        |");
  1828. X    mvaddstr(18,35,"|                           |");
  1829. X    mvaddstr(19,35,"| LATEST: allow concurrent  |");
  1830. X    mvaddstr(20,35,"|    high score setting     |");
  1831. X    mvaddstr(21,35,"`---------------------------'");
  1832. X
  1833. X    /* draw game border */
  1834. X    mvaddstr(0,14, ".----------.");
  1835. X    mvaddstr(21,14,"`----------'");
  1836. X    for (y=1; y<21; y++)
  1837. X        mvaddstr(y,14,"|          |");
  1838. X
  1839. X    /* display the title */
  1840. X    mvaddstr(3,17,"TETRIX");
  1841. X    refresh();
  1842. X}
  1843. X
  1844. X/**************************************************************/
  1845. XPlay()
  1846. X{
  1847. Xwhile ((Key != QUIT_KEY) && NewPiece()) {
  1848. X    FallingDown = 0;
  1849. X    do {    /* do until we can't Advance the piece */
  1850. X        if (FallingDown) Pause = 0;
  1851. X        else Pause = CurrentPause;
  1852. X        while (Pause) {        /* do this until pause runs out */
  1853. X            Pause--;
  1854. X            switch (Key) {
  1855. X                case BOSS_KEY     : Boss(); break;
  1856. X                case QUIT_KEY     : CurrentPause = 0;
  1857. X                case FALL_KEY     : FallingDown = 1;
  1858. X                            UPSCORE(20-Row);
  1859. X                            Pause = 0; break;
  1860. X                case RIGHT_KEY    :
  1861. X                case L_RIGHT_KEY  : MoveRight(); break;
  1862. X                case LEFT_KEY     :
  1863. X                case L_LEFT_KEY   : MoveLeft(); break;
  1864. X                case ROTATE_KEY   :
  1865. X                case L_ROTATE_KEY : Rotate(); break;
  1866. X                case NULL_KEY     : break;
  1867. X                default           : if (Beep) beep();
  1868. X                }
  1869. X            GetKey();
  1870. X            }
  1871. X        } while (AdvancePiece());
  1872. X    UPSCORE(5);
  1873. X    TestRows();
  1874. X    }
  1875. X}
  1876. X
  1877. X/*********************************************************************/
  1878. XScoreIt()
  1879. X{
  1880. X    register int  oldmask,fd,i,j;
  1881. X
  1882. X    oldmask = umask(0);
  1883. X    if ((fd=open(SCORE_FILE,O_CREAT|O_RDONLY,0666)) != -1) {
  1884. X        read(fd,High,sizeof(High));
  1885. X        close(fd);
  1886. X    }
  1887. X    else {
  1888. X    for(i=0; i<10; i++)
  1889. X        High[i].Score = 0;
  1890. X    for(i=0; i<10; i++)
  1891. X        strncpy("         ",High[i].Name,10);
  1892. X    }
  1893. X    umask(oldmask);
  1894. X
  1895. X    for (i=0; i<10; i++)        /* place this guy */
  1896. X        if (High[i].Score <= ThisScore) break;
  1897. X
  1898. X    if (i < 10 )            /* insert this score */
  1899. X    {
  1900. X        HighsChanged = 1;
  1901. X        for (j=9; j>i; j--)        /* move down others */
  1902. X            if (High[j-1].Score)
  1903. X            {
  1904. X                High[j].Score = High[j-1].Score;
  1905. X                strncpy(High[j].Name,High[j-1].Name,10);
  1906. X            }
  1907. X        cuserid((char *) High[i].Name);
  1908. X        High[i].Score = ThisScore;
  1909. X    }
  1910. X
  1911. X    if (HighsChanged)
  1912. X    {
  1913. X        if ((fd=open(SCORE_FILE,O_RDWR)) != -1) {
  1914. X            write(fd,High,sizeof(High));
  1915. X            close(fd);
  1916. X        }
  1917. X        else mvaddstr(22,0,"Couldn't open high score file.");
  1918. X    }
  1919. X    
  1920. X}
  1921. X
  1922. X/***********************************************************************/
  1923. XDrawScore()
  1924. X{
  1925. X    register int j;
  1926. X
  1927. X    mvaddstr( 5,35,"|     Hit 'm' for menu      |");
  1928. X    mvaddstr( 6,35,"|                           |");
  1929. X    mvaddstr( 7,35,"|        HIGH SCORES        |");
  1930. X    mvaddstr( 8,35,"| 1.                        |");
  1931. X    mvaddstr( 9,35,"| 2.                        |");
  1932. X    mvaddstr(10,35,"| 3.                        |");
  1933. X    mvaddstr(11,35,"| 4.                        |");
  1934. X    mvaddstr(12,35,"| 5.                        |");
  1935. X    mvaddstr(13,35,"| 6.                        |");
  1936. X    mvaddstr(14,35,"| 7.                        |");
  1937. X    mvaddstr(15,35,"| 8.                        |");
  1938. X    mvaddstr(16,35,"| 9.                        |");
  1939. X    mvaddstr(17,35,"|10.                        |");
  1940. X    mvaddstr(18,35,"|                           |");
  1941. X    mvaddstr(19,35,"|                           |");
  1942. X    mvaddstr(20,35,"|                           |");
  1943. X    
  1944. X    for (j=0; j<10; j++)
  1945. X       if (High[j].Score)
  1946. X       {
  1947. X          mvprintw(j+8,41,"%-s",(char *)High[j].Name);
  1948. X          mvprintw(j+8,54,"%d",High[j].Score);
  1949. X       }
  1950. X    refresh();
  1951. X
  1952. X}
  1953. X
  1954. X/*********************************************************************/
  1955. XBoss()
  1956. X{    register int x,y;
  1957. X
  1958. X    clear();
  1959. X    refresh();
  1960. X    ioctl (0, TCSETA, &origtty);
  1961. X    system("sh </dev/tty >/dev/tty");
  1962. X    ioctl (1, TCSETAW, &tty);
  1963. X    clear();
  1964. X    DrawMenu();
  1965. X    /* restore board */
  1966. X    for (x=0; x<BOARD_WIDE; x++) 
  1967. X        for (y=0; y<BOARD_HIGH; y++) 
  1968. X            PUTCH(x,y,Board[x][y]);
  1969. X    refresh();
  1970. X
  1971. X}
  1972. X
  1973. X/*********************************************************************/
  1974. XGetKey()
  1975. X{
  1976. X/*    fflush(stdout); */
  1977. X    Key = NULL_KEY;
  1978. X    top:
  1979. X    if (read (0, combuf, 1) == 0) 
  1980. X        return;
  1981. X    else Key = (*combuf&0177); 
  1982. X    goto top;
  1983. X}
  1984. X
  1985. X/************************************************************************/
  1986. X/* Could be a macro for speed but cpp runs out of tree space in CanMove */
  1987. XIS_FREE(x,y)
  1988. Xint x,y;
  1989. X{
  1990. X    if ((y < 0) || (y >= BOARD_HIGH) || (x < 0) || (x >= BOARD_WIDE))
  1991. X        return(0);
  1992. X    if (Board[x][y] != NO_CHAR)
  1993. X        return(0);
  1994. X    else return(1);
  1995. X}
  1996. X
  1997. X/*********************************************************************/
  1998. XTestRows()
  1999. X{    register int x,y,tempy,fullrow;
  2000. X    int marked[BOARD_HIGH];
  2001. X
  2002. Xfor (y=0; y<BOARD_HIGH; y++) {
  2003. X    marked[y] = 0;
  2004. X    for (x=0; x<BOARD_WIDE; x++)
  2005. X        Temp[x][y] = NO_CHAR;
  2006. X    }
  2007. X
  2008. X/* main loop to traverse Board, looking for fullrows */
  2009. X/* as it looks, it copies non full ones over to Temp */
  2010. Xtempy=BOARD_HIGH-1;
  2011. Xfor (y=BOARD_HIGH-1; y>=0; y--) {
  2012. X    fullrow = 1;
  2013. X    for (x=0; x<BOARD_WIDE; x++)        /* check for any holes at all */
  2014. X        if (IS_FREE(x,y)) { fullrow = 0; break; }
  2015. X    if (fullrow) {
  2016. X        marked[y]++;
  2017. X        CurrentPause--;            /* speed up the game */
  2018. X    }
  2019. X    else    {
  2020. X        for (x=0; x<BOARD_WIDE; x++)
  2021. X            Temp[x][tempy] = Board[x][y];
  2022. X        tempy--;
  2023. X        }
  2024. X    }
  2025. X
  2026. X/* flash the rows that will die */
  2027. Xfor (tempy=1; tempy<5; tempy++)
  2028. X    for (y=BOARD_HIGH-1; y>=0; y--) 
  2029. X        if (marked[y]) {    
  2030. X            UPSCORE(30-y);
  2031. X            for (x=0; x<BOARD_WIDE; x++)    
  2032. X                PUTCH(x,y,BRITE_CHAR);
  2033. X            refresh();
  2034. X            for (x=0; x<BOARD_WIDE; x++)    
  2035. X                PUTCH(x,y,NO_CHAR);
  2036. X            refresh();
  2037. X            }
  2038. X
  2039. X/* Move temp back to Board */
  2040. Xfor (y=BOARD_HIGH-1; y>=0; y--) {
  2041. X    for (x=0; x<BOARD_WIDE; x++)
  2042. X        PUTCH(x,y,Temp[x][y]);
  2043. X    refresh();
  2044. X    }
  2045. X}
  2046. X
  2047. X/***********************************************************/
  2048. XLeave()
  2049. X{
  2050. X    erase();
  2051. X    mvaddstr(22,48,"Tetrix says Bye\n");
  2052. X    mvaddstr(23,0,"");
  2053. X    refresh();
  2054. X    sleep(1);
  2055. X    ioctl (0, TCSETA, &origtty);
  2056. X    exit(0);
  2057. X}
  2058. END_OF_FILE
  2059. if test 9501 -ne `wc -c <'tet.c'`; then
  2060.     echo shar: \"'tet.c'\" unpacked with wrong size!
  2061. fi
  2062. # end of 'tet.c'
  2063. fi
  2064. echo shar: End of shell archive.
  2065. exit 0
  2066.